5<?php

    include_once('./include/UserClass.php');
	include_once("./include/ActivitiesClass.php");
    $UserClass = new UserClass();
	$ActivClass = new ActivitiesClass();
    
    if ($_GET['action']=='upd' || $_GET['action']=='del')		// update or delete Activity
    {
        $id = $_GET['id'];
        
        $result  = $ActivClass->getActiveDetail($id);
        $row = mysql_fetch_array($result);
        
        $amount= $row['amount'];
     //   $password=$row['password'];
        $type = $row['type'];
    }
    else
    {
        $amount=null;
        $password=null;
    }

switch($_GET['action'])    
{
    case 'new': {echo "<h3>Add new Activity</h3>"; break;}
    case 'upd': {echo "<h3>Update Activity</h3>"; break;}
    case 'del': {echo "<h3>Delete Activity</h3>"; break;}
}
    ?>


<div id='createActiveCont'>
<form action="index.php" method="get" name="activeMain" onsubmit="return check();">
    <input type='hidden' name='tabID' value='sellerMain'>   
    <input type='hidden' name='subID' value='newactive'>
    <input type='hidden' name='go' value='ok'>



<?php
   

if ($_GET['action']=='new')
{
    echo "
        Campaign Type: <br>
            <select name='type' id='type' class='inputSelect' onchange='changeActive()'>
                <option value='0'>Choose type</option>
                <option value='Banner'>Banner</option>
                <option value='Mail'>Mail</option>
                <option value='Mobile'>Mobile Marketing</option>
				<option value='Pop'>Pop-up</option>
				<option value='Professional'>Professional Site</option>
				<option value='SEO'>SEO</option>
				<option value='Improvement'>Site Improvement</option>
				<option value='Social'>Social Network</option>
				<option value='Video'>Video</option>
				
            </select> <br><br>

	 ";
	}
	?>
		
		
		<div id="maildiv" style="display: none;">
		<b> Amount Mail:</b>     
			<input type="text" id="amount" name="amount" value="" class='inputField'/> <br> <br> 
		<b> Duration (in days):</b>    
		<input type="text" id="duration" name="duration" value="" class='inputField'/> <br> <br> 
		
		<b> Description: </b><br> 
		<textarea rows="5" cols="30" id="descr"></textarea><br><br>
		
		<?php
				
		?>
	   </div> 

<?php
        switch($_GET['action'])    
        {
        case 'new': {echo "<input type='hidden' name='action' value='new'>"; break;}
        case 'del': {echo "<input type='hidden' name='action' value='del'>
                            <input type=\"hidden\" name=\"id\" value=\"$id\">";break;}
        case 'upd': {echo "<input type='hidden' name='action' value='upd'>
                           <input type=\"hidden\" name=\"id\" value=\"$id\">";break;}
        }
?>    

        <br> <input type="submit" value="Submit" class="newButton"/>
      </div> 
</form>


<?php
		




    if ($_GET['action']=='del')
        echo "<script language=\"javascript\">
                     document.getElementById('name').readOnly = true;
                     document.getElementById('password').readOnly = true;
                    function check(){return true}
              </script>";
    else if ($_GET['action']=='new' || $_GET['action']=='upd')
        {
            echo "<script language=\"javascript\">
                    function check()
                    {
                        flag = true
                        if(document.getElementById('name').value=='')
                        {
                            alert('Please enter user name')
                            flag = false
                        }
                        else if(document.getElementById('password').value=='')
                        {
                            alert('Please enter user password')
                            flag = false
                        }";
            if ($_GET['action']=='new') 
                echo  "else if(document.getElementById('type').value=='')
                        {
                            alert('Please enter user user type')
                            flag = false
                        }";
               echo    "
                        return flag
                    }
              
              
            function isNumber(val,val2)
            {
                check = true;
                if (val=='' || isNaN(val))
                {   
                    alert('Please enter '+val2);
                    check = false;
                } 
                else if (val<0)
                {
                    alert('Please enter '+val2+' bigger then 0');
                    check = false;
                }
                else if (val.indexOf('.') != (-1))
                {
                    alert('Please enter integer as '+val2);
                    check = false;
                }
                return check;
            }
           </script>";
        }   
?>
<script type='text/javascript'>
			function changeActive(){
					var e = document.getElementById("type");
					var selectedOption = e.options[e.selectedIndex].value;
					document.getElementById("maildiv").style.display = "none";
						if (selectedOption=='0'){
							window.alert('none');
								
						}
						if (selectedOption=='Banner'){
							window.alert('Banner');
								
						}
						if (selectedOption=='Mail'){
							document.getElementById("maildiv").style.display = "block";
						}
						if (selectedOption=='Mobile'){
							window.alert('Mobile Marketing');
						}
						if (selectedOption=='Pop'){
							window.alert('Pop-up');
						}
						if (selectedOption=='Professional'){
							window.alert('Professional Site');
						}
						if (selectedOption=='SEO'){
							window.alert('SEO');
						}
						if (selectedOption=='Improvement'){
							window.alert('Site Improvement');
						}
						if (selectedOption=='Social'){
							window.alert('Social Network');
						}
						if (selectedOption=='Video'){
							window.alert('Video');
						}
			}
              </script>